package indi.zhifa.expshare.class001.chemicalmatch.controller;


import indi.zhifa.expshare.class001.chemicalmatch.service.IChemicalCompatibleService;
import indi.zhifa.engine.core.common.entity.web.RestResponse;
import indi.zhifa.engine.core.common.web.ann.ZhiFaRestController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Slf4j
@Validated
@RequiredArgsConstructor
@RequestMapping(value = "api/chemicalCompatible")
@ZhiFaRestController
@Tag(name = "化学兼容性接口")
public class FeiChaoExcelController {

    final IChemicalCompatibleService mExcelReaderService;

    @Operation(summary = "导入")
    @PostMapping("/import")
    public RestResponse<String> readExcel(@RequestPart("file") MultipartFile pFileRequest) throws IOException {
        mExcelReaderService.readExcel(pFileRequest);
        return RestResponse.ok("导入成功");
    }

    @Operation(summary = "清空")
    @DeleteMapping("/clear")
    public RestResponse<String> clear() {
        mExcelReaderService.clear();
        return RestResponse.ok("清除成功");
    }


}
